package com.gin.kotlin.no_gay_alliance.runner

import androidx.room.Room
import com.gin.kotlin.no_gay_alliance.app.App
import com.gin.kotlin.no_gay_alliance.app.AppRunner
import com.gin.kotlin.no_gay_alliance.database.NgaDatabase

/**
 * 初始化数据库
 */
class DatabaseRunner : AppRunner {
    /**
     * 执行的任务内容
     * @param app [App]
     */
    override fun run(app: App) {
        val klass = NgaDatabase::class.java
        app.database = Room.databaseBuilder(app, klass, klass.simpleName)
            // 版本硬升级，正式版需移除
//            .fallbackToDestructiveMigration()
            .allowMainThreadQueries()
            .build()
    }
}